package com.akaovi.chatroom.process;

import com.akaovi.chatroom.scene.SendMessBoard;

/**
 * @author akaovi
 * @version 1.0
 * @description 处理用户看得见的消息界面的内容，建立类统一管理消息，并且让消息界面是响应式的
 * @date 2022/12/7 22:41
 * @since 2022/12/7 22:41
 */
public class ChatMessManage {
    private static StringBuilder currentUserMessageText = new StringBuilder();

    /**
     * 新增聊天内容
     * @param text 文本
     * @return 新增后的聊天内容
     */
    public static String add(String text) {
        currentUserMessageText.append(text).append("\n");
        // 告诉界面更新内容
        SendMessBoard.callForText();
        return text;
    }

    /**
     * 清空聊天内容内容
     * @return 返回被清空地聊天内容
     */
    public static String removeAll() {
        String s = currentUserMessageText.toString();
        currentUserMessageText = new StringBuilder();
        SendMessBoard.callForText();
        return s;
    }

    /**
     * 获取全部聊天内容
     * @return 全部聊天内容
     */
    public static String get() {
        return currentUserMessageText.toString();
    }
}
